package com.lb.activity.config;

import com.github.pagehelper.PageHelper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * Created with IntelliJ IDEA.
 * Description: pagehelper配置
 * User: liubin
 * Date: 2017-11-16
 * Time: 下午 6:09
 * @author 001030
 */
@Configuration
public class PageHelperConfig {
    /**
     * pageHelper ，也可配置在application.perperties
     * @return
     */
  @Bean
  public PageHelper pageHelper(){
    PageHelper pageHelper = new PageHelper();
    Properties properties = new Properties();
    properties.setProperty("offsetAsPageNum","true");
    properties.setProperty("rowBoundsWithCount","true");
    properties.setProperty("reasonable","true");
    properties.setProperty("supportMethodsArguments", "true");
    properties.setProperty("returnPageInfo", "check");
    properties.setProperty("params", "count=countSql");
    //配置mysql数据库的方言
    properties.setProperty("dialect","mysql");
    pageHelper.setProperties(properties);
    return pageHelper;
  }
}
